from utils import gcd, lcm

# 10n + i    n
# ------- = ---
# 10i + d    d
#
# n < d 
#

den_prod = 1
nom_prod = 1
for i in range(1, 10):
    for d in range(1, 10):
        for n in range(1, d):
            if (10 * n + i) * d == (10 * i + d) * n:
                den_prod *= d
                nom_prod *= n

print den_prod / gcd(nom_prod, den_prod)

